package E2013;

import javax.xml.crypto.Data;
import java.util.Scanner;

public class Exam1 {
    public static void main(String[] args) {
        int[] arrDays1 = new int[]{0,31,28,31,30,31,30,31,31,30,31,30,31};
        int[] arrDays2 = new int[]{0,31,29,31,30,31,30,31,31,30,31,30,31};
        int days =0;
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入年份：");
        String year = sc.nextLine();
        System.out.println("请输入月份：");
        String month = sc.nextLine();
        System.out.println("请输入日期：");
        String day = sc.nextLine();
        // 判断是否为闰年
        int a = Integer.parseInt(year);
        int b = Integer.parseInt(month);
        int c = Integer.parseInt(day);
        if ( (a%4==0 && a%100!=0) || a%400==0){
            // 是闰年
            for (int i=0;i<arrDays2.length;i++){
                days+=arrDays2[i];
                if (b==i){
                    days-=arrDays2[i];
                    days+=c;
                    break;
                }
            }
        }else{
            // 不是闰年
            for (int i=0;i<arrDays1.length;i++){
                days+=arrDays1[i];
                if (b==i){
                    days-=arrDays1[i];
                    days+=c;
                    break;
                }
            }
        }
        System.out.println("该日期是该年的第"+days+"天");

        //判断是否闰年
//        int iYear = Integer.parseInt(year);
//        int iMonth = Integer.parseInt(month);
//        int iDay = Integer.parseInt(day);
//
//        if((iYear % 4 ==0 && iYear % 100 != 0) || iYear % 400 ==0) {
//            for(int i=0;i<iMonth;i++) {
//                days += arrDays2[i];
//            }
//        } else {
//
//            for(int i=0;i<iMonth;i++) {
//                days += arrDays1[i];
//            }
//        }
//        days += iDay;
//        System.out.println("该日期是该年的第"+days+"天");

    }
}
